package settingsapp.settings.toggle;

import android.content.Context;

/**
 * provides static methods which return SettingsChanger objects
 * with the given settings type
 */
public class ToggleSettingFactory
{
	public static enum ToggleSettingType
	{
		airplaneMode("Airplane Mode"),
		bluetooth("Bluetooth"),
		wifi("Wifi"),
		orientation("Orientation Lock"),
		gps("GPS"),
		unset("Unset");
		
		private final String description;
		
		private ToggleSettingType(String description)
		{
			this.description = description;
		}
		
		public String toString() { return description; }
	}
	
	/**
	 * returns a SettingsChanger for the given SettingType
	 */
	public static ToggleSettingChanger createSettingsObject(Context context, ToggleSettingType type)
	{
		switch (type)
		{
		case airplaneMode:
			return new SettingAirplaneMode(context, 0);
		case bluetooth:
			return new SettingBluetooth(context, 1);
		case wifi:
			return new SettingWifi(context, 2);
		case orientation:
			return new SettingOrientationLock(context, 3);
		case gps:
			return new SettingGps(context, 4);
		case unset:
			return new SettingUnset(context, 5);
		default:
			return null;		// never happens
		}
	}
	
	/**
	 * returns a SettingsChanger for the given SettingType (same as index used i getSettingTypes())
	 */
	public static ToggleSettingChanger createSettingsObject(Context context, int typeIndex)
	{
		return createSettingsObject(context, ToggleSettingType.values()[typeIndex]);
	}
	
	/**
	 * returns an array of the String representations of the different setting types
	 */
	public static CharSequence[] getSettingTypes()
	{
		final ToggleSettingType[] settingTypes = ToggleSettingType.values();
		final CharSequence[] items = new CharSequence[settingTypes.length];
		
		for (int i = 0; i < settingTypes.length; i++)
			items[i] = settingTypes[i].toString();
		
		return items;
	}
}
